{% extends 'fanli.html' %}

{% block content-center %}
    <h3  class="page-header">用户漏斗图</h3>
    <!-- 为 ECharts 准备一个具备大小（宽高）的Dom -->
    <div id="main" style="width: 800px;height:600px;"></div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        var yy01 = '';
        var yy02 = '';

        // 同步执行
        $.ajaxSettings.async = false;

        $.getJSON('/fanli/json_get_user_funnel', function (json) {
            yy01 = json.access_uv;
            yy02 = json.goshop_uv;
            yy03 = json.buy_user_cnt;
        });

        // alert(xx)

       // 指定图表的配置项和数据
        option = {
            title : {
                text: '',
                subtext: ''
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c}%"
            },
            toolbox: {
                show : true,
                feature : {
                    mark : {show: true},
                    dataView : {show: true, readOnly: false},
                    restore : {show: true},
                    saveAsImage : {show: true}
                }
            },
            legend: {
                data : ['访问','goshop','购买']
            },
            calculable : true,
            series : [
                {
                    name:'漏斗图',
                    type:'funnel',
                    width: '80%',
                    //sort : 'ascending',
                    data:[
                        {value:yy01, name:'访问'},
                        {value:yy02, name:'goshop'},
                        {value:yy03, name:'购买'},
                    ]
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        //window.onresize = myChart.resize;
    </script>
{% endblock %}